<template>
  <div class="el-wrapper" :style="{width: 'calc(100vw - 100px)',margin:'0 auto'}">
    <el-table :data="pageList">
      <el-table-column label="ID" width="50" prop="id"></el-table-column>
      <el-table-column label="姓名" width="150" prop="username"></el-table-column>
      <el-table-column label="性别" width="50" prop="gender"></el-table-column>
      <el-table-column label="生日" width="100" prop="birth"></el-table-column>
      <el-table-column label="地址" width="180" prop="address"></el-table-column>
      <el-table-column label="操作" width="280">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage1"
      :page-sizes="[5, 10, 20, 30]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    ></el-pagination>
  </div>
</template>

<script>
export default {
  props: {
    pageList: {
      type: Array
    },
    currentPage1: {
      type: Number,
      default: 1
    },
    pageSize: {
      type: Number,
      default: 5
    },
    total: {
      type: Number
    }
  },
  methods: {
    handleSizeChange(size) {
      this.$emit("sizeChangeClick", size);
    },
    handleEdit(index, row) {
      this.$emit("editClick", { index, row });
    },
    handleDelete(index, row) {
      this.$emit("deleteClick", { index, row });
    },
    handleCurrentChange(val) {
      this.$emit("currentClick", val);
    }
  }
};
</script>

<style>
</style>